import request from "@/utils/request";

const ACCOUNTOWNER_BASE_URL = "/api/v1/accountOwners";

const AccountOwnerAPI = {
    /** 获取账户归属人分页数据 */
    getPage(queryParams?: AccountOwnerPageQuery) {
        return request<any, PageResult<AccountOwnerPageVO[]>>({
            url: `${ACCOUNTOWNER_BASE_URL}/page`,
            method: "get",
            params: queryParams,
        });
    },
    /**
     * 获取账户归属人表单数据
     *
     * @param id 账户归属人ID
     * @returns 账户归属人表单数据
     */
    getFormData(id: number) {
        return request<any, AccountOwnerForm>({
            url: `${ACCOUNTOWNER_BASE_URL}/${id}/form`,
            method: "get",
        });
    },

    /** 添加账户归属人*/
    add(data: AccountOwnerForm) {
        return request({
            url: `${ACCOUNTOWNER_BASE_URL}`,
            method: "post",
            data: data,
        });
    },

    /**
     * 更新账户归属人
     *
     * @param id 账户归属人ID
     * @param data 账户归属人表单数据
     */
     update(id: number, data: AccountOwnerForm) {
        return request({
            url: `${ACCOUNTOWNER_BASE_URL}/${id}`,
            method: "put",
            data: data,
        });
    },

    /**
     * 批量删除账户归属人，多个以英文逗号(,)分割
     *
     * @param ids 账户归属人ID字符串，多个以英文逗号(,)分割
     */
     deleteByIds(ids: string) {
        return request({
            url: `${ACCOUNTOWNER_BASE_URL}/${ids}`,
            method: "delete",
        });
    }
}

export default AccountOwnerAPI;

/** 账户归属人分页查询参数 */
export interface AccountOwnerPageQuery extends PageQuery {
    name?: string;
    remark?: string;
}

/** 账户归属人表单对象 */
export interface AccountOwnerForm {
    id?:  number;
    name?:  string;
    remark?:  string;
    createTime?:  Date;
    updateTime?:  Date;
}

/** 账户归属人分页对象 */
export interface AccountOwnerPageVO {
    id?: number;
    name?: string;
    remark?: string;
    createTime?: Date;
    updateTime?: Date;
}
